﻿using System;
using System.Collections.Generic;
using System.Text;
using AF_ORM.CORE;
using System.Data;
using Bussiness.Entity;
using log4net;
namespace Bussiness.Manager
{


    public class PT_ToolPKTTManager : Bussiness.ManagerBase.PT_ToolPKTTManagerBase
    {
        private static readonly ILog _logger = LogManager.GetLogger(typeof(PT_ServiceListManager).Name);
        public static PT_ToolPKTTManager CreateInstant()
        {
            return new PT_ToolPKTTManager();
        }
        public PT_ToolPKTTEntity GetByCode(string Code)
        {
            List<PT_ToolPKTTEntity> lst = SelectByCodeLST(Code);
            if (lst != null && lst.Count > 0)
                return lst[0];
            return null;
        }
        public PT_ToolPKTTEntity GetByID(int ID)
        {
            List<PT_ToolPKTTEntity> lst = SelectByIDLST(ID);
            if (lst != null && lst.Count > 0)
                return lst[0];
            return null;
        }

        public DataTable GetAll()
        {
            try
            {
                string sql = @"SELECT 
                                Row_Number() OVER (ORDER BY Id) AS STT,
                                Id,Code,Name,
                                CASE WHEN IsActive=1 THEN N'Hoạt động' ELSE N'Không hoạt động' END AS IsActive
                           FROM PT_ToolPKTT
                           WHERE IsDeleted=0 "
                               + " ORDER BY Name";
                return SqlHelper.ExecuteDataTable(Config.ConnectionConfig.ConnectionString, CommandType.Text, sql);
            }
            catch (Exception ex)
            {
                _logger.Debug(ex.Message);
                return new DataTable();
            }
        }
    }
}

